/// @TOPDESC: TeaPod means this is a thread pool implmentation

#ifndef XM_EVLOOPTEAPOD_HH
#define XM_EVLOOPTEAPOD_HH

#include <functional>
#include <string>
#include <vector>
#include <memory>

#include "XM_noncopyable.hh"
#include "pch.hh"

XM_NAMESPACE_BEGIN

struct EvLoop;
struct EvLoopThread;

struct EvLoopTeaPod : private XM_noncopyable
{
    using TreadInitCallback = std::function<void(EvLoop*)>;

    EvLoopTeaPod(EvLoop* elop, const std::string& nameArg);
    ~EvLoopTeaPod(); // deinit func
    // size_t not be negative ?
    void setThreadNum(size_t teanums)
    {
        threadNum__ = teanums;
    }

    EvLoop* getNextLoop();

    std::vector<EvLoop*> getAllLoops();

    bool isStarted() const { return started__; }

    const std::string name() const { return name__; }

private:
    EvLoop* elop__;
    std::string name__;
    bool started__;
    int threadNum__;
    int next__;
    std::vector<std::unique_ptr<EvLoopTread>> threads__;
    std::vector<EvLoop*> loops__;
};

XM_NAMESPACE_END

#endif // header file protect